import React, {Component} from 'react';
import {StyleSheet, View, Text, Button} from 'react-native';
import NavigationUtil from '../navigator/NavigationUtil';
import AsyncStorage from '@react-native-community/async-storage';

export default class LoginPage extends Component {
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}> LoginPage </Text>
        <Button title="Sign in!" onPress={this._signInAsync} />
      </View>
    );
  }
  _signInAsync = async () => {
    await AsyncStorage.setItem('userToken', 'abc');
    NavigationUtil.resetToHomePage({
      navigation: this.props.navigation,
    });
  };
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
});
